
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

#define MAXBUFFSIZE 256


int connfd;
int main(int argc,char *argv[])
{
    int sockfd,n;
    char recvbuff[MAXBUFFSIZE]="oh  my god,it can run.";
    struct sockaddr_in servaddr;
    sockfd = socket(AF_INET,SOCK_STREAM,0);
    if(sockfd < 0)
    {
        printf("socket created failed!\n");
        return -1;
    }
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(atoi(argv[1]));
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);  //INADDR_ANY

    printf("connecting ...........\n");

    if(connect(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0)
    {
        printf("connet server failed!\n");
        return -1;
    }
    write(sockfd,recvbuff,sizeof(recvbuff));
    return 0;
}
